﻿using System;

using System.Collections.Generic;
using System.Text;

namespace Silvermoon.Animations
{
    public class ExponentialEase : EasingFunctionBase
    {
        public static readonly ExponentialEase In = new ExponentialEase { Mode = EasingMode.EaseIn };
        public static readonly ExponentialEase Out = new ExponentialEase { Mode = EasingMode.EaseOut };
        public static readonly ExponentialEase InOut = new ExponentialEase { Mode = EasingMode.EaseInOut };

        public ExponentialEase()
            : base()
        {
            Exponent = -3d;
        }

        public ExponentialEase(double a)
            : base()
        {
            Exponent = a;
        }

        private double a;
        private double d;

        public double Exponent
        {
            get { return a; }
            set
            {
                a = value;
                d = Math.Exp(Exponent) - 1;
            }
        }

        protected override float EaseValue(float normalizedTime)
        {
            double t = normalizedTime;
            double c = Math.Exp(Exponent * t) - 1;
            return (float)(c / d);
        }
    }
}
